package com.ambulance.project.manager.utils;

import com.ambulance.common.utils.ServletUtils;
import com.ambulance.framework.security.LoginUser;
import com.ambulance.framework.security.service.TokenService;
import com.ambulance.project.biz.entity.Hospital;
import com.ambulance.project.biz.service.HospitalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/***
 *  @description 外援登陆后获取登陆者信息
 *  @author zhao
 *  @date: 2020/5/12
 *  @version: v1.0
 */
@Component(value = "helperCommonUtil")
public class HelperCommonUtil {

    @Autowired
    private TokenService tokenService;

    @Autowired
    private HospitalService hospitalService;
    public Hospital getMgtUserLoginResult() {

        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        Long deptId = loginUser.getUser().getDeptId();
        Hospital hospital = hospitalService.getById(deptId);
        return hospital;
    }
}
